//
//  Datai20ViewController.m
//  Depressed.domo
//
//  Created by rimi on 16/5/26.
//  Copyright © 2016年 薛涛. All rights reserved.
//

#import "Datai20ViewController.h"

@interface Datai20ViewController ()

@property (strong, nonatomic) UITextField *nameText;
@property (strong, nonatomic) UITextField *ageText;
@property (strong, nonatomic) NSArray *dataArray;
@property (strong, nonatomic) void(^callback)(NSArray *array);
@end

@implementation Datai20ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor purpleColor];
    _nameText = [[UITextField alloc]initWithFrame:CRM(300, 300, 200, 50)];
    _nameText.placeholder = @"请输入姓名";
    _nameText.textColor = [UIColor brownColor];
    [self.view addSubview:_nameText];
    
    _ageText = [[UITextField alloc]initWithFrame:CRM(200, 200, 200, 50)];
    _ageText.placeholder = @"请输入年龄";
    _ageText.textColor = [UIColor brownColor];
    [self.view addSubview:_ageText];
    
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(100, 100, 100, 50);
    btn.backgroundColor = [UIColor redColor];
    [btn setTitle:@"ok" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnTaped:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
}

-(void)btnTaped:(UIButton *)sender {
    _dataArray = @[_nameText.text,_ageText.text];
    if (_callback) {
        _callback(_dataArray);
    }
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)updateHomeData:(void (^)(NSArray *))block{
    _callback = block;

}

@end
